﻿Public Class booking
    Inherits System.Web.UI.Page
    Dim username As String = CStr(Session("username"))
    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
       
    End Sub

    Protected Sub btnView_Click(sender As Object, e As EventArgs) Handles btnView.Click
        If (ddlService.SelectedValue = "Car Rental") Then

            Dim pxy As New carReference.CarService
            Session.Add("pxy", pxy)
            Session.Add("Type", "Car")
            gvVacay.DataSource = pxy.GetRentalCarAgencies(ddlState.SelectedItem.Text, txtCity.Text)
            gvVacay.DataBind()



        Else
            If (ddlService.SelectedValue = "Hotel") Then

                Dim pxy As New hotelService.HotelService
                Session.Add("pxy", pxy)
                Session.Add("Type", "Hotel")
                gvVacay.DataSource = pxy.getHotel(txtCity.Text, ddlState.SelectedItem.Text)
                gvVacay.DataBind()


            Else
                If (ddlService.SelectedValue = "Flight") Then

                    Dim pxy As New AirService.AirService
                    Session.Add("pxy", pxy)
                    Session.Add("Type", "Air")
                    gvVacay.DataSource = pxy.GetAirCarriers(txtCity.Text, ddlState.SelectedValue.ToString)
                    gvVacay.DataBind()


                End If
        End If
        End If

        If (ddlService.SelectedValue = "Car Rental") Then
            lblFindCars.Visible = True
            txtAgency.Visible = True
            btnSearchCar.Visible = True
        End If

    End Sub

    Protected Sub btnSearchCar_Click(sender As Object, e As EventArgs) Handles btnSearchCar.Click
        Dim pxy As New carReference.CarService
        gvCars.DataSource = pxy.GetCar(txtAgency.Text)
        gvCars.DataBind()
    End Sub

 

    Protected Sub btnAddChard_Click(sender As Object, e As EventArgs) Handles btnAddChard.Click
        Dim Type As String = Session("Type")
        Dim vacay As New hotelService.Vacation
        Dim pxy As New hotelService.HotelService
        If (Type = "Car") Then

            For row As Integer = 0 To gvCars.Rows.Count - 1
                Dim chkbox As CheckBox = gvCars.Rows(row).FindControl("CheckBox1")
                Dim txtbox As TextBox = gvCars.Rows(row).FindControl("TextBox1")

                vacay.Type = Type
                vacay.Quantity = txtbox.Text
                vacay.Price = CDbl(gvCars.Rows(row).Cells(3).Text)
                pxy.insertCart(vacay, username)
            Next

        Else
            If (Type = "Hotel") Then

            Else

            End If
        End If



    End Sub
End Class